/*
 * Copyright 2011-2020 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0.
 * See `LICENSE` in the project root for license information.
 */

package me.ijleex.mgmt.system.user.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import me.ijleex.mgmt.commons.util.snowflake.IdWorker;
import me.ijleex.mgmt.system.user.entity.User;
import me.ijleex.mgmt.system.user.mapper.UserMapper;
import me.ijleex.mgmt.system.user.service.IUserService;

/**
 * 用户 服务层实现
 *
 * @author liym
 * @since 2019-03-14 11:03:53 By 'codegen'
 */
@Service
public class UserServiceImpl implements IUserService {

    private final UserMapper mapper;

    public UserServiceImpl(UserMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public int insertUser(User user) {
        long id = IdWorker.getId();
        user.setId(id);
        return this.mapper.insert(user);
    }

    @Override
    public int deleteUserByIds(String ids) {
        return this.mapper.delete(ids);
    }

    @Override
    public int updateUser(User user) {
        return this.mapper.update(user);
    }

    @Override
    public List<User> getUserList(User user) {
        return this.mapper.selectList(user);
    }

    @Override
    public User getUserById(Long id) {
        return this.mapper.selectById(id);
    }

}
